using System;
using System.Collections.Generic;
using System.Text;
using TerraExplorerX;
using System.Collections;

namespace Tpro6Container.Class
{
    public class FindFangAn
    {
        private SGWorld _SWorld = null;

        public FindFangAn(SGWorld w3D)
        {
            _SWorld = w3D;
        }

        public ArrayList GetFanAnKeyList()
        {
            ArrayList list = new ArrayList();

            if (_SWorld == null)
            {
                return list;
            }

            int iItemID=_SWorld.ProjectTree.GetNextItem(0, ItemCode.ROOT);
           
            while (iItemID > 0)
            {
                AddItemToList(iItemID, list);
                iItemID = _SWorld.ProjectTree.GetNextItem(iItemID, ItemCode.NEXT);
            }

            return list;
        }

        private void AddItemToList(int ItemID,ArrayList List)
        {
            if (_SWorld.ProjectTree.IsGroup(ItemID))
            {
                int iItemID = _SWorld.ProjectTree.GetNextItem(ItemID, ItemCode.CHILD);
                AddItemToList(iItemID, List);
            }
            else
            {
                ITerraExplorerObject6 tEObj = null;

                if(ItemID > 0)
                {
                    tEObj=(ITerraExplorerObject6)_SWorld.ProjectTree.GetObject(ItemID);
                    if (tEObj.ObjectType == ObjectTypeCode.OT_PRESENTATION)
                    {
                        List.Add(tEObj);
                    }
                }
            }
        }
    }
}
